#encoding: utf-8
=begin

这是我的批量删除以前微博的脚本
Created by dplord on 2015-04-29

=end


require 'net/http'
require 'uri'
require 'nokogiri'


def sendGet(myUrl)
  url = URI.parse(myUrl)
  http = Net::HTTP.new(url.host, url.port)

  headers = { 
    "Host" => "weibo.cn" ,
    'Referer' => 'http://profil.wp.pl/login.html',
    'Content-Type' => 'application/x-www-form-urlencoded',
    'User-Agent' => 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36',
    "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Cookie" => "你的微博cookie字段"
   }

  resp = http.get(url, headers)  
  return resp.body.force_encoding('utf-8')
end

def delWeibo
  a = sendGet("http://weibo.cn/你的微博数字id/profile?page=13")
  html = Nokogiri::HTML(a)
  html.css('a.cc').each{|a|
    if a['href'].include?"mblog"
      sendGet(a['href']+"&type=del&act=del")
    end
  }
end

while true
  delWeibo
end